home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / tools / reslist.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  70 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "stdio.h"
  18.  
  19. #define BACKMAGIC    (('P'<<24)+('A'<<16)+('U'<<8)+('L'<<8))
  20. #define RESSIZE        (4+4+32)
  21. #define MAXRES        (100)
  22.  
  23. char nametab[MAXRES][32];
  24. int offsettab[MAXRES];
  25. int lengthtab[MAXRES];
  26.  
  27. main(argc,argv)
  28. int argc;
  29. char **argv;
  30. {
  31.     int i, n, pos;
  32.     FILE *inf;
  33.     long magic;
  34.  
  35.     if(argc<2) {
  36.     fprintf(stderr,"usage: reslist progin\n");
  37.     exit(1);
  38.     }
  39.     inf = fopen(argv[1],"r");
  40.     if(!inf) {
  41.     fprintf(stderr,"reslist: can't open input file %s for reading\n",argv[1]);
  42.     exit(1);
  43.     }
  44.     for(i=0; i<3; i++) {
  45.     fseek(inf,-(4+i*4),SEEK_END);
  46.     magic = 5;
  47.     fread(&magic,sizeof(long),1,inf);
  48.     if(magic != BACKMAGIC) {
  49.         fprintf(stderr,"reslist: no resources found\n");
  50.         exit(1);
  51.     }
  52.     }
  53.     fseek(inf,-(4+3*4),SEEK_END);
  54.     fread(&n,sizeof(long),1,inf);
  55.     printf("\nThis file contains %d resources: \n",n);
  56.     for(i=0; i<n; i++) {
  57.     fseek(inf,-(4+3*4+4)-i*RESSIZE,SEEK_END);
  58.     fread(&lengthtab[i],sizeof(long),1,inf);
  59.     fseek(inf,-(4+3*4+4+4)-i*RESSIZE,SEEK_END);
  60.     fread(&offsettab[i],sizeof(long),1,inf);
  61.     fseek(inf,-(4+3*4+4+4+32)-i*RESSIZE,SEEK_END);
  62.     fread(nametab[i],32,1,inf);
  63.     }
  64.     for(i=0; i<n; i++) {
  65.     printf("    name: %s length %d offset %d\n",
  66.               nametab[i],lengthtab[i],offsettab[i]);
  67.     }
  68.     printf("\n");
  69. }
  70.